package org.stars.dao.config;

import java.util.Map;

import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;
import org.stars.config.MessageBundle;
import org.stars.dao.sqlmapper.SqlMapper;
import org.stars.dao.sqlmapper.macro.Macro;
import org.stars.datastructure.map.CaseInsensitiveHashMap;

@Root(name="daoconfig")
public class DaoConfigImpl implements DaoConfigRaw, DaoConfig {

	public DaoConfigImpl()
	{
		sources=new Sources();
		dataSources=new DataSources();
		typeAliases=new TypeAliases();
		typeHandlers=new TypeHandlers();
		macros=new Macros();
		macroMap=new CaseInsensitiveHashMap<Macro>();
	}
	
	@Element
	protected Sources sources;
	
	@Element(required=false)
	protected DataSources dataSources;
	
	@Element(required=false)
	protected String defaultDataSource;
	
	@Element(name="macros",required=false)
	protected Macros macros;
	
	@Element(required=false)
	protected String eventHandlerClass;
	
	@Element(required=false)
	protected String stackTraceClass;
	
	@Element(required=false)
	protected TypeAliases typeAliases;
	
	@Element(required=false)
	protected TypeHandlers typeHandlers;
	 
	protected Map<String, SqlMapper> sqlMapperMap;
	
	protected Map<String, Macro> macroMap;
	
	protected Map<String, TypeAlias> typeAliasMap;
	
	protected MessageBundle messageBundle;
	
	/* (non-Javadoc)
	 * @see org.stars.dao.config.DaoConfig#getMacroMap()
	 */
	@Override
	public Map<String, Macro> getMacroMap() {
		return macroMap;
	}

	public void setMacroMap(Map<String, Macro> macroMap) {
		this.macroMap = macroMap;
	}

	/* (non-Javadoc)
	 * @see org.stars.dao.config.DaoConfig#getSources()
	 */
	@Override
	public Sources getSources() {
		return sources;
	}

	public void setSources(Sources sources) {
		this.sources = sources;
	}

	/* (non-Javadoc)
	 * @see org.stars.dao.config.DaoConfig#getDataSources()
	 */
	@Override
	public DataSources getDataSources() {
		return dataSources;
	}

	public void setDataSources(DataSources dataSources) {
		this.dataSources = dataSources;
	}

	/* (non-Javadoc)
	 * @see org.stars.dao.config.DaoConfig#getDefaultDataSource()
	 */
	@Override
	public String getDefaultDataSource() {
		return defaultDataSource;
	}

	public void setDefaultDataSource(String defaultDataSource) {
		this.defaultDataSource = defaultDataSource;
	}

	/* (non-Javadoc)
	 * @see org.stars.dao.config.DaoConfig#getEventHandlerClass()
	 */
	@Override
	public String getEventHandlerClass() {
		return eventHandlerClass;
	}

	public void setEventHandlerClass(String eventHandlerClass) {
		this.eventHandlerClass = eventHandlerClass;
	}

	/* (non-Javadoc)
	 * @see org.stars.dao.config.DaoConfig#getStackTraceClass()
	 */
	@Override
	public String getStackTraceClass() {
		return stackTraceClass;
	}

	public void setStackTraceClass(String stackTraceClass) {
		this.stackTraceClass = stackTraceClass;
	}

	/* (non-Javadoc)
	 * @see org.stars.dao.config.DaoConfig#getTypeAliases()
	 */
	@Override
	public TypeAliases getTypeAliases() {
		return typeAliases;
	}

	public void setTypeAliases(TypeAliases typeAliases) {
		this.typeAliases = typeAliases;
	}

	/* (non-Javadoc)
	 * @see org.stars.dao.config.DaoConfig#getTypeHandlers()
	 */
	@Override
	public TypeHandlers getTypeHandlers() {
		return typeHandlers;
	}

	public void setTypeHandlers(TypeHandlers typeHandlers) {
		this.typeHandlers = typeHandlers;
	}
	
	/* (non-Javadoc)
	 * @see org.stars.dao.config.DaoConfig#getMacros()
	 */
	@Override
	public Macros getMacros() {
		return macros;
	}

	public void setMacros(Macros macros) {
		this.macros = macros;
	}

	@Override
	public Map<String, SqlMapper> getSqlMapperMap() {		
		return sqlMapperMap;
	}

	public void setSqlMapperMap(Map<String, SqlMapper> sqlMapperMap) {
		this.sqlMapperMap = sqlMapperMap;
	}

	@Override
	public MessageBundle getMessageBundle() {
		return messageBundle;
	}

	public void setMessageBundle(MessageBundle messageBundle) {
		this.messageBundle = messageBundle;
	}

	public void setTypeAliasMap(Map<String, TypeAlias> value) {
		typeAliasMap=value;
		
	}
	
	@Override
	public Map<String, TypeAlias> getTypeAliasMap() {
		return typeAliasMap;
	}

}
